<?php
namespace Home\Controller;
use Think\Controller;

use Weixin\Wechat;
use Weixin\WechatAuth;

class QlindexController extends CommonController {
    //保存微信openid  
    private $weixin_openid = ""; 
    //保存从微信得到的code   
    private $code="";
    //获得菜单中设置的state值  
    private $state="";
     //获得用户信息  
    private $userinfor="";
    //默认进行的函数 获取到用户的openid并且存到session里面
    public function _initialize(){
      
        if (isset($_GET['code']) && isset($_GET['state']) ){  
        $this->weixin_openid = GetOpenid($_GET['code']);  
        $this->code = $_GET['code'];  
        $this->state = $_GET['state']; 
            if(session("weixin_openid") == "" || session("weixin_openid")=="code is invalid."){
                session("weixin_openid",$this->weixin_openid);
            }
        $this->state = $_GET['state'];  
        session("weixin_openid",$this->weixin_openid);
        //echo $resultStr;  

        }else{ 
            return ;  
        }  
        //把openid存入session
        //$_SESSION['weixin_openid']=$this->weixin_openid;  

        // session("weixin_openid","o9Hr_syQN_1HPN9KLr7pqwwYwCvM");
        // $this->userinfor=$this->getinfobyopenid($this->weixin_openid); //获取用户信息

       

    }
    public function qlindex(){
        $this->display("qlindex");
    }
}